package general;

public class Cell {

    private int opA;
    private int opB;
    private int opC;
    private int opD;
    private char type;

    //
    //default constructor
    //
    public Cell () {
        type = 'X'; //default cell type is invalid
        opA = opB = opC = opD = 0;
    }

    //
    //return the value of opA
    //
    public int getOpA () {
        return opA;
    }

    //
    //set the value of OpA
    //
    public void setOpA (int val) {
        this.opA = val;
    }

    //
    //return the value of opB
    //
    public int getOpB () {
        return opB;
    }

    //
    //set the value of opB
    //
    public void setOpB (int val) {
        this.opB = val;
    }

    //
    //return the value of opC
    //
    public int getOpC () {
        return opC;
    }

    //
    //set the value of opC
    //
    public void setOpC (int val) {
        this.opC = val;
    }

    //
    //return the value of opD
    //
    public int getOpD () {
        return opD;
    }

    //
    //set the value of opD
    //
    public void setOpD (int val) {
        this.opD = val;
    }

    //
    //get the cell type
    //Note: cell type represented by a single char
    //
    public char getType () {
        return type;
    }

    //
    //set the cell type
    //Note: cell type represented by a single char
    //
    public void setType (char val) {
        this.type = val;
    }

    //
    //set all of the operands, opA through opD
    //
    public void setOperands (int new_a, int new_b, int new_c, int new_d) {
        setOpA(new_a);
        setOpB(new_b);
        setOpC(new_c);
        setOpD(new_d);
    }
    
    //
    //return the MAC result for the current operands
    //Note: two's complement handled at the functional unit level
    //
    public int compute () {
        return  opA * opB + opC + opD;
    }
    
    //
    //print the type of the cell
    //
    public void printType() {
        System.out.print(type);
    }

    //
    //print the operands of the cell
    //
    public void printOperands () {
        System.out.print(opA);
        System.out.print('/');
        System.out.print(opB);
        System.out.print('/');
        System.out.print(opC);
        System.out.print('/');
        System.out.print(opD);        
    }


}

